<?php
use app\common\model\Role;
?>
{include file="../app/common/admin/lib/header.html" title="后台用户管理"}
<div class="page-header border-bottom clearfix">
    <h2 class="left">后台用户管理<span>在这里对后台用户进行管理</span></h2>
    <a href="{:url('user/adminuser/add?extra_res=admin_user')}" class="btn btn-success btn-sm right">添加管理员</a>
    <a class="btn btn-default btn-sm right js_advancedSearchBtn">搜索</a>
</div>
<div class="search-form js_advancedForm" style="{if !$search_filter}display:none;{/if}">
<form action="{:url("/user/admin_user/index")}" method="get" class="js_lotterySearchForm">
    <input type="hidden" name="is_advenced" value="1">
    <input type="hidden" name="status" value="{$status}">
    <input type="hidden" name="extra_res" value="admin_user">
    <p>
      <label for="" class="search-f-label">名字：</label>
      <input type="text" class="search-f-ipt1" name="search_filter[user_name]" value="{$search_filter.user_name}">
    </p>
    <p>
    <label for="" class="search-f-label">添加时间：</label>
      <input type="text" class="search-f-ipt1 search-f-ipt2" name="search_filter[start_date]" value="{$search_filter.start_date}" id="startDate">
      <span class="search-f-line"></span>
      <input type="text" class="search-f-ipt1 search-f-ipt2" name="search_filter[stop_date]" value="{$search_filter.stop_date}" id="stopDate">
    </p>
    <p><label for="" class="search-f-label"></label><button type="submit" class="btn btn-success btn-xs js_searchBtn">搜索</button></p>
</form>
</div>
<!--start:列表-->
<table class="list-table">
  <caption>按状态：
    <a href='{:url("/user/admin_user?status=1")}' {if $status == 1} class="label label-primary" {else} class="label label-default" {/if}>正常</a>
    <a href='{:url("/user/admin_user?status=0")}' {if $status == 0} class="label label-primary" {else} class="label label-default" {/if}>已禁用</a>
  </caption>
  <thead>
    <tr>
      <th style="width:20px;"><input type="checkbox" class="selectAll"></th>
      <th>用户名</th>
      <th>角色</th>
      <th>时间</th>
      <th>操作</th>
    </tr>
  </thead>
  <tbody>
  {if (isset($list))}
      {foreach $list['data'] as $k=>$v}
      <tr id="dataList{$v.id}" {if $k%2 == 1} class="bg-gray" {/if}>
          <td><input type="checkbox" class="listSelect"></td>
          <td>{$v.user_name}</td>
          <td>{:Role::get_role_title($v.id)}</td>
          <td>{$v.add_time|time_format}</td>
          <td>
              {if $status == 1}

                {if $v.type != 20}
                <a href="{:url("/user/adminuser/edit?id={$v.id}&extra_res=admin_user")}" class="btn btn-info btn-xs"><i class="icon-edit icon-white"></i>编辑</a>
                {/if}
                <a href="{:url('/user/adminuser/delete')}" class="btn btn-danger btn-xs deleteOne"><i class="icon-trash icon-white"></i>禁用</a>
              {else}
                <a href="{:url("/user/adminuser/change_status?id={$v.id}&status=1")}" class="btn btn-success btn-xs changeStatus"><i class="icon-trash icon-white"></i>恢复</a>
              {/if}

          </td>
      </tr>
      {/foreach}
  {else /}
  <tr>
      <td class="txtleft" colspan="5">暂无数据</td>
  </tr>
  {/if}
  </tbody>
  {if $status == 1}
  <tfoot><tr><td><input type="checkbox" class="selectAll"></td><td colspan="4"><a href="{AnUrl("user/admin/back_user/delete")}" class="btn btn-danger btn-xs deleteAll">批量禁用</a></td></tr></tfoot>
  {/if}
</table>

<div id="pages"></div>

<!--end:列表-->
<script>
$(function(){
  // 高级搜索时间验证
  $('.js_searchBtn').click(function(e){
      e.preventDefault();
      var thisObj   = $(this);
      var startDate = $.trim($('#startDate').val());
      var stopDate  = $.trim($('#stopDate').val());
      if (startDate > stopDate) {
          showMsg('结束时间应大于等于开始时间');
          return;
      }
      thisObj.closest('form').submit();
  });

});
</script>
{include file="../app/common/admin/lib/footer.html"}